<?php
/*
 * @Created by: wangchengcheng
 * @Author: wangchengcheng
 * @Date: 2020-01-08 17:19:46
 * @LastEditors  : wangchengcheng
 * @LastEditTime : 2020-01-08 19:51:35
 */

namespace App\Observers;

use App\Notifications\SiteAudit;

class SiteObserver extends BaseObserver
{
    public function updated($site)
    {
        // restore() triggering both restored() and updated()
        if(! $site->isDirty('deleted_at')){
            //$site->audit is string
            if($site->isDirty('audit') && intval($site->audit) === 1){
                $site->socialiteUser->notify(new SiteAudit);
            }

            flash_success('修改成功');
        }
    }
}
